package com.tairanchina.wiki.api.model.wiki.navigation;

import java.net.URI;

/**
 * Created by 周靖捷 on 2016/10/1.
 */
public class ProjectSubNavigation implements NavigationElement {
    String title;
    URI linkedResource;

    public String getTitle() {
        return title;
    }

    public ProjectSubNavigation setTitle(String title) {
        this.title = title;
        return this;
    }

    public URI getLinkedResource() {
        return linkedResource;
    }

    public ProjectSubNavigation setLinkedResource(URI linkedResource) {
        this.linkedResource = linkedResource;
        return this;
    }

    @Override
    public String toMarkdown() {
        StringBuffer sb = new StringBuffer();
        sb.append("[").append(title == null ? "" : title);
        sb.append("]").append("(").append(linkedResource == null ? "" : linkedResource.toString()).append(")");
        return sb.toString();
    }

    public static void main(String[] args) {
        ProjectNavigation navigation = new ProjectNavigation();
        navigation.setTitle("泰玄网络wiki系统")
                .addNavigationItems(new ProjectSubNavigation().setTitle("HOME").setLinkedResource(URI.create("index.md")))
                .addNavigationItems(new ProjectSubNavigationGroupTips().setTips("版本说明"))
                .addNavigationItems(new ProjectSubNavigationElement().setTitle("版本说明").setLinkedResource(URI.create("index.md")))
                .addNavigationItems(new ProjectSubNavigationSeperator());
        System.out.println(navigation.toMarkdown());
    }
}
